﻿<%@ Page Title="Manage SlideShow" Language="C#" MasterPageFile="~/AdminMaster.master" AutoEventWireup="true"
    CodeBehind="ManageSlideShow.aspx.cs" Inherits="ShopOnline.ManageSlideShow" Theme="ShopOnline" %>

<%@ Register Assembly="ShopOnline" Namespace="ShopOnline.Controls" TagPrefix="cc" %>
<%@ Register Src="~/Controls/Common/DataPagerCtrl.ascx" TagName="DataPager" TagPrefix="uc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <link href="css/smart_wizard.css" rel="stylesheet" type="text/css" />
    <link href="css/BusinessCard.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function deleteImageByID(id) {
            var ok = confirm("Are you sure to delete this item?");
            if (!ok)
                return;
            var hidID = document.getElementById("<%= hidID.ClientID %>");
            hidID.value = id;
            var btn = document.getElementById("<%= btnDelete.ClientID %>");
            btn.click();
        }

        function deleteAllItems() {
            var ok = confirm("Are you sure to delete all item(s)?");
            if (!ok)
                return;

            var hidID = document.getElementById("<%= hidID.ClientID %>");
            hidID.value = "-1";
            var btn = document.getElementById("<%= btnDelete.ClientID %>");
            btn.click();
        }

        function showGrid(visible) {
            var grid = document.getElementById("divGrid");
            if (visible)
                grid.style.display = "block";
            else
                grid.style.display = "none";
        }

        function openWindow(url) {
            wnd_gallery.navigateUrl = url;
            wnd_gallery.title = "Gallery";
            wnd_gallery.open();
        }

        function showEditForm(effect) {
            $('.addButton').hide();
            $('.cancelButton').show();
            $('#divEditForm').show();
            if (effect != undefined && effect != null)
                $('#divEditForm').show("slide", { direction: "up" }, 300);
            else
                $('#divEditForm').show();
        }

        function hideEditForm(effect) {
            $('.addButton').show();
            $('.cancelButton').hide();
            if (effect != undefined && effect != null)
                $('#divEditForm').hide("slide", { direction: "up" }, 300);
            else
                $('#divEditForm').hide();
        }

        function clearAllField() {
            $('#divEditForm input[type=text]').val('');
            $('#divEditForm textarea').val('');
            $('#<%=hidID.ClientID %>').val('');
        }

    </script>
    <cc:WindowManager ID="windowManager" runat="server" />
    <cc:Window ID="gallery" runat="server" URL="Default.aspx" Title="A" WindowWidth="660"
        WindowHeight="500" AllowResizing="false" AllowScrolling="false" />
    <input type="button" class="addButton" onclick="clearAllField();showEditForm(1);"
        title="Add New Slide" />
    <input type="button" class="cancelButton" onclick="hideEditForm(1);" title="Cancel" />
    <div id='divEditForm' class='editForm' style='display: none'>
        <table>
            <tr>
                <td>
                    Title
                    <label class='required'>
                        *</label>
                </td>
                <td>
                    <asp:TextBox ID="txtTitle" runat="server" class="tb7" ValidationGroup="Save" />
                    <asp:RequiredFieldValidator ValidationGroup="Save" ID="RequiredFieldValidator3" runat="server"
                        class='requiredField' ErrorMessage="" Text='' Display="Dynamic" ControlToValidate="txtTitle"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    URL
                </td>
                <td>
                    <asp:TextBox ID="txtURL" runat="server" class="tb7" ValidationGroup="Save" />
                </td>
            </tr>
            <tr>
                <td valign="top">
                    Image
                    <label class='required'>
                        *</label>
                </td>
                <td>
                    <asp:FileUpload Style="height: 28px" ID="file" runat="server" class="tb7" /><br />
                    965x295
                </td>
            </tr>
            <tr>
                <td style="vertical-align: top;">
                    Description
                </td>
                <td>
                    <div class='tb8'>
                        <asp:TextBox ID='txtDescription' TextMode="MultiLine" Rows="3" runat="server"></asp:TextBox>
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td>
                    <button id="btnSubmit" type="submit" runat="server" onserverclick="btnSave_OnClick"
                        validationgroup="Save" class="button btn-cart">
                        <span><span>Save</span></span></button>
                    <br />
                    <br />
                    <label class='required'>
                        *</label>
                    required
                </td>
            </tr>
        </table>
    </div>
    <div style='height: 10px'>
        &nbsp;</div>
    <cc:CustomGrid Width="100%" AllowRowSelect="false" GridLines="None" CssClass="clientGrid"
        ID="gridSlides" runat="server" AutoGenerateColumns="false" DataKeyField="ID"
        OnNeedDataSource="gridSlides_OnNeedDataSource" AllowPaging="false">
        <Columns>
            <cc:CustomTemplateField UniqueName="Name" HeaderText="Image" ItemStyle-Width="30%">
                <ItemTemplate>
                    <a onclick='<%# "openWindow(\"SlideShow.aspx?slideshow=1&id=" + Eval("ID").ToString() + "\"); return false;"%>'
                        style='cursor: pointer;'>
                        <img title='Click to view full image.' style='border: 0px none white; vertical-align: middle'
                            src="images/wallpaper-icon.png" height='24px' />
                    </a><a id="lnkURL" class='Image-name' style='color: #ff339c' href='<%# Eval("URL") != DBNull.Value ?  Eval("URL") : ""  %>'
                        runat="server">
                        <%# Eval("Title") %>
                    </a>
                </ItemTemplate>
            </cc:CustomTemplateField>
            <cc:CustomTemplateField HeaderText="Description" ItemStyle-Width="40%" HeaderStyle-Width="45%">
                <ItemTemplate>
                    <%# ShopOnline.Utilities.GetSubString(Eval("Description").ToString(), 50) %>
                    ...
                </ItemTemplate>
            </cc:CustomTemplateField>
            <cc:CustomTemplateField HeaderText="Active" ItemStyle-Width="10px" HeaderStyle-Width="10px"
                ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <asp:CheckBox ID='chkActive' ToolTip="Activate or Deactivate" Checked='<%# (bool)Eval("Active") %>'
                        runat="server" ItemID='<%# Eval("ID") %>' AutoPostBack="true" OnCheckedChanged="chkActive_OnCheckedChanged" />
                </ItemTemplate>
            </cc:CustomTemplateField>
            <cc:CustomTemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                ItemStyle-Width="10px" HeaderStyle-Width="10px" HeaderText="Edit">
                <ItemTemplate>
                    <asp:LinkButton ID="btnEdit" runat="server" ToolTip="Edit" OnClick="btnEdit_OnClick"
                        ItemID='<%# Eval("ID") %>'>
                        <asp:Image ImageUrl="~/images/Edit.gif" runat="server" ID="imgDelete" />
                    </asp:LinkButton>
                </ItemTemplate>
            </cc:CustomTemplateField>
            <cc:CustomTemplateField ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                ItemStyle-Width="10px" HeaderStyle-Width="10px" HeaderText="">
                <ItemTemplate>
                    <asp:LinkButton ID="btnDelete" runat="server" ToolTip="Delete" OnClientClick='<%# string.Format("deleteImageByID({0}); return false;", Eval("ID")) %>'>
                        <asp:Image ImageUrl="~/images/delete_icon.gif" runat="server" ID="imgEdit" />
                    </asp:LinkButton>
                </ItemTemplate>
                <HeaderTemplate>
                    <asp:LinkButton ID="btnDeleteAll" runat="server" ToolTip="Delete All" OnClientClick='deleteAllItems(); return false;'>
                        <asp:Image ImageUrl="~/images/delete_icon.gif" runat="server" ID="imgDeleteAll" />
                    </asp:LinkButton>
                </HeaderTemplate>
            </cc:CustomTemplateField>
        </Columns>
    </cc:CustomGrid>
    <uc:DataPager PageSize="10" ID="dataPager" runat="server" OnPageIndexChanged="dataPager_OnPageIndexChanged" />
    <asp:Button Style="display: none" ID="btnDelete" runat="server" OnClick="btnDelete_OnClick" />
    <asp:HiddenField ID="hidID" runat="server" />
</asp:Content>
